package com.hp.ams.ongoing.netatendimento.view.converter;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

import com.hp.ams.ongoing.netatendimento.model.entity.TipoRegistro;

@FacesConverter(value="tipoRegistroConverter")
public class TipoRegistroConverter implements Converter {

	@Override
	public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
		String[] arr = arg2.split("-");
		TipoRegistro vo = new TipoRegistro();
		vo.setIdTipoRegistro(new Integer(arr[0]));
		vo.setDsTipoRegistro(arr[1]);
		return vo;
	}

	@Override
	public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {
		TipoRegistro vo = (TipoRegistro) arg2;
		return vo.toString();
	}

}
